From 5f08d4eba0c5bb51294ee89d4285f3cc6dde925f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 20 Aug 2013 23:11:50 -0700 Subject: [PATCH] Emacs should no longer hang at startup on kFreeBSD. Applied upstream patch (in conjunction with 5113963): Port close-on-exec pty creation to FreeBSD 9.1-RELEASE. * configure.ac (PTY_OPEN): If posix_openpt with O_CLOEXEC fails and reports EINVAL, try it again without O_CLOEXEC. This should port PTY_OPEN to FreeBSD 9, which stupidly rejects O_CLOEXEC. What were they thinking? Origin: upstream, commit: 5113964, 5c41cec3858f1828303b67be634b8c39937c8580 Added-by: Rob Browning Provided-By: Paul Eggert Bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15129 --- ChangeLog | 8 ++++++++ configure.ac | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 961c913d578..bdabe50a1bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-08-21 Paul Eggert + + Port close-on-exec pty creation to FreeBSD 9.1-RELEASE (Bug#15129). + * configure.ac (PTY_OPEN): If posix_openpt with O_CLOEXEC fails + and reports EINVAL, try it again without O_CLOEXEC. This should + port PTY_OPEN to FreeBSD 9, which stupidly rejects O_CLOEXEC. + What were they thinking? + 2013-03-11 Glenn Morris * Version 24.3 released. diff --git a/configure.ac b/configure.ac index 28d9d847604..0c283ef3779 100644 --- a/configure.ac +++ b/configure.ac @@ -3555,7 +3555,7 @@ case $opsys in AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) dnl if HAVE_POSIX_OPENPT if test "x$ac_cv_func_posix_openpt" = xyes; then - AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_NOCTTY)]) + AC_DEFINE(PTY_OPEN, [do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (0)]) AC_DEFINE(PTY_NAME_SPRINTF, []) dnl if HAVE_GETPT elif test "x$ac_cv_func_getpt" = xyes; then -- 2.30.2